<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
    <div id="app">
      米:<input type="text" v-model="mi">
      <hr>
      千米: <input type="text" v-model="km">
      <hr>
      <input type="text" v-model="msg">
    </div>
    <script src="./vue.js"></script>
    <script>
      let vm=new Vue({
          el:"#app",
          data(){
            return {
              mi:"",
              km:"",
              msg:"你好"
            }
          },
          methods: {
            
          },
          watch:{
            mi(newVal){
              this.km=newVal/1000
            },
            km(newVal){
              this.mi=newVal*1000
            }
          }
          
        })

        // vm.$el
        // vm.$data
        // 实例外部操作watch属性
        vm.$watch('msg',(newVal,old)=>{
          console.log(newVal,old)
      
        })
    </script>
</body>
</html>